#include "1my_server.hpp"
#include "1my_tcp.hpp"
#include <unistd.h>

static void Usage(std::string proc)
{
    std::cout << "\n\rUsage: " << proc << " port\n" << std::endl;
}

int main(int argc, char* argv[]) //./server port
{
    if(argc != 2)
    {
        Usage(argv[0]);
        exit(0);
    }
    uint16_t port = std::stoi(argv[1]);

    Server server;
    TcpServer* tcp = new TcpServer(port, std::bind(&Server::HandlePackage, &server, std::placeholders::_1));
    tcp->Init();
    tcp->Start();

    return 0;
}